#ifndef ZBLOG_CGI_H
#define ZBLOG_CGI_H

#include <utils/print.h>

#define ARGS_BUF_SIZE (1024*1024) // 1M
#define MAX_URI_LEN 250

/*
    AJAX_RSP_FMT:
    @arg1: %s, true means success and false means failure
    @arg2: %s, show message on web (if not empty)
    @arg3: %s, run this script on web (if not empty)
    @arg4: %s, redirect to this location (if not empty)
*/
#define AJAX_RSP_FMT \
"{"\
  "\"success\": %s,"\
  "\"message\": \"%s\","\
  "\"script\": \"%s\","\
  "\"redirect\": \"%s\""\
"}"
/*
    AJAX_SUCCESS_FMT:
    @arg1: %s, show message on web (if not empty)
*/
#define AJAX_SUCCESS_FMT \
"{\"success\": true, \"message\": \"%s\", \"script\": \"location.reload()\"}"
/*
    AJAX_FAIL_FMT:
    @arg1: %s, show message on web (if not empty)
*/
#define AJAX_FAIL_FMT \
"{\"success\": false, \"message\": \"%s\"}"

extern long g_start_time;
extern char *g_test_blog_title;
extern char *g_test_blog_content;
extern char *g_site_name;
extern char *g_copyright;

char *get_datetime_str(void);
int is_online(holyreq_t *req);
void cgi_index(holyreq_t *req);
void cgi_is_online(holyreq_t *req);
void cgi_login(holyreq_t *req);
void cgi_logout(holyreq_t *req);
void cgi_show_blog(holyreq_t *req);
void cgi_add_blog(holyreq_t *req);
void cgi_modify_blog(holyreq_t *req);
void cgi_del_blog(holyreq_t *req);

#endif // ZBLOG_CGI_H
